package com.cn.JUC.utils.case1;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @Title Lock 和 Condition
 * @Description Java SDK 并发包通过 Lock 和 Condition 两个接口来实现管程，
 * 其中 Lock 用于解决互斥问题，Condition 用于解决同步问题。
 * @Author CAI ZHAI
 * @Date 2021/8/30 22:00
 **/
@Slf4j
public class zTest{
    
    public static void main(String[] args){
        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(3,6,3,TimeUnit.SECONDS,
                new LinkedBlockingQueue<>(10000));
    
        for(int i = 0; i<10000; i++){
            threadPoolExecutor.execute(new ThreadCase());
        }
        try{
            Thread.sleep(3000);
        }catch(InterruptedException e){
            e.printStackTrace();
        }
        
        log.info(LockConditiong.value + "");  //线程未跑完，输出value了
    }
}
